<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" id="html">
    <head>
        <title></title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <base href="<?= base_url(1); ?>" />
        <link type="text/css" href="css/main.css?v=<?= $config['version'] ?>" rel="stylesheet" />
        <style type="text/css">
            #ss {
                color:blue;
            }
        </style>
        <script src="js/time.js?"></script>
        <script charset="utf-8" src="edit/kindeditor.js"></script>
		<script charset="utf-8" src="edit/lang/zh_CN.js"></script>
		<script charset="utf-8" src="edit/plugins/code/prettify.js"></script>
		
        <script type="text/javascript">
            var i = 0;
            function addp()
            {
                if (i < 4)
                {
                    i++;
                }
                else
                {
                    alert('up to four!');
                    return;
                }
                str = '<p id="p' + i + '"><input type="text" size="39" placeholder="<?= translate('PLASE_INPUT_ITEM') ?>" name="row[item][]" id="itemid' + i + '" class="autocomplete" table="type_object" autocomplete="off" >&nbsp;&nbsp;' +
                        '<input type="text" size="8" placeholder="<?= translate('PLASE_INPUT_AMOUNT') ?>" name="row[amount][]" id="num' + i + '" ></p>';
                $("#add").append(str);
                autocomplete();
            }
            function removep()
            {
                if (i > 0)
                {
                    $("#p" + i).remove();
                    i--;
                }
            }

            KindEditor.ready(function(K) {
                var editor1 = K.create('textarea[id="msg"]', {
                    //width : w,
                    cssPath: 'edit/plugins/code/prettify.css',
                    uploadJson: 'edit/php/upload_json.php',
                    fileManagerJson: 'edit/php/file_manager_json.php',
                    allowFileManager: true,
                    urlType: "domain",
                    afterCreate: function() {
                        var self = this;
                        K.ctrl(document, 13, function() {
                            self.sync();
                            K('form[name=rowForm]')[0].submit();
                        });
                        K.ctrl(self.edit.doc, 13, function() {
                            self.sync();
                            K('form[name=rowForm]')[0].submit();
                        });
                    }
                });
                prettyPrint();
            });
            
        </script>
    </head>
    <body>
        <?php include(VIEWPATH . 'common/main_header.php'); ?>
        <form action="" method="POST" id="rowForm">
            <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tablegrid tableedit">
                <tr><td><?= translate('SELECT_AREA') ?>:</td><td><?= $arealist ?></td></tr>
                <tr><td><?= translate('BROADCAST_MSG') ?>:</td>
                    <td>
                    <!--  <textarea rows="3" cols="60" name="row[content][msg]" id="msg" ><?= $row['content']['msg'] ?></textarea>-->
                    <textarea cols="70" rows="20" name="row[content][msg]" id="msg1"><?= $row['content']['msg'] ?></textarea>
                    </td>
                </tr>
         <!--   <tr><td><?= translate('BROADCAST_COUNT') ?>:</td>
                    <td><input type="text" name="row[repeatCount]" id="repeatCount" size="25" value="<?= $row['repeatCount'] ?>" /></td>
                </tr>
                <tr><td><?= translate('BROADCAST_INTERVAL') ?>:</td>
                    <td><input type="text" name="row[interval]" id="interval" size="25" value="<?= $row['interval'] ?>"/><?= translate('SECONDS') ?></td>
                </tr>  -->
                <tr>
                    <td><?= translate('BROADCAST_FREQUENCE') ?>:</td>
                    <td>
                        <?= $frequence ?>
                    </td>
                </tr>
                <tr class="hide frequence repeat">
                    <td><?= translate('BROADCAST_MAX_EXCUTE_TIMES') ?>:</td>
                    <td><input type="text" name="row[maximums]" id="maximums" value="<?= $row['maximums'] ?>" /></td>
                </tr>
                <tr class="hide frequence repeat">
                    <td><?= translate('RUNTIME') ?>:</td>
                    <td>
                        <span><input type="text" name="row[content][crontime][minute]" id="cronminute" class="crontime" placeholder="0-59" size="3" value="<?= $row['content']['crontime']['minute'] ?>" /> (<?= translate('MINUTE') ?>)</span>
                        <span><input type="text" name="row[content][crontime][hour]" id="cronhour" class="crontime" placeholder="0-23" size="3" value="<?= $row['content']['crontime']['hour'] ?>" /> (<?= translate('HOUR') ?>)</span>
                        <span><input type="text" name="row[content][crontime][day]" id="cronday" class="crontime" placeholder="1-31" size="3" value="<?= $row['content']['crontime']['day'] ?>"/> (<?= translate('DAY') ?>)</span>
                        <span><input type="text" name="row[content][crontime][month]" id="cronmonth" class="crontime" placeholder="1-12" size="3" value="<?= $row['content']['crontime']['month'] ?>"/> (<?= translate('MONTH') ?>)</span>
                        <span><input type="text" name="row[content][crontime][week]" id="cronweek" class="crontime" placeholder="0-6" size="2" value="<?= $row['content']['crontime']['week'] ?>"/> (<?= translate('WEEK') ?>)</span>
                        <a href="javascript:;" class="help" module="cron"><?= translate('README') ?></a>
                        <span id="cron_id"></span>
                    </td>
                </tr>
                <tr>
                    <td><?= translate('STARTTIME') ?>:</td>
                    <td><input type="text" name="row[starttime]" id="starttime" size=25px 
                    value="<?= $row['starttime'] ? date("Y-m-d H:i:s", $row['starttime']) : $row['starttime'] ?>" class="datepicker" showtime="true" /></td>
                </tr>
                <tr class="hide frequence repeat">
                    <td><?= translate('EXPIRETIME') ?>:</td>
                    <td><input type="text" name="row[expiretime]" id="expiretime" value="<?= $row['expiretime'] ? date("Y-m-d H:i:s", $row['expiretime']) : $row['expiretime'] ?>" class="datepicker" showtime="true" /></td>
                </tr>
                <tr>
                    <td id='ss'><?= translate('BROADCAST_SELECT') ?>:</td>
                    <td>
                  <!--   <input type="checkbox" name="row[channel][]" value="5" <?= in_array(5, $row['channel'])? "checked":"" ?> > <?= translate('BROADCAST_CHANNEL_SYSTEM') ?> -->
                            <input type="checkbox" name="row[channel][]" value="7" <?= in_array(7, $row['channel'])? "checked":"" ?>> <?= translate('BROADCAST_CHANNEL_BROADCAST') ?> 
                             	<input type="checkbox" name="row[channel][]" value="8" <?= in_array(8, $row['channel'])? "checked":"" ?>> <?= translate('BROADCAST_CHANNEL_MARQUEE') ?>			
                                </td>
                                </tr>
                                <tr>
                                    <td></td><td>
                                        <input type="submit" value="<?= translate('SUBMIT') ?>" id="submit"/> <input type="reset" value="<?= translate('RESET') ?>" id="reset"/>
                                    </td>
                                </tr>
                                </table>
                                </form>
                                <script type="text/javascript">
                                    SG.init("core.form", function() {
                                        $.formValidator.initConfig({formid: "#rowForm", submitonce: true})
                                        $("#word").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                                        $("#maximums").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp:"intege",datatype:"enum", onerror: '<?= translate('C_ONLY_NUM') ?>'});
                                        $("#repeatCount").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp:"intege",datatype:"enum", onerror: '<?= translate('C_ONLY_NUM') ?>'});
                                        $("#interval").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp:"intege",datatype:"enum", onerror: '<?= translate('C_ONLY_NUM') ?>'});
                                        $("#type").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                                        $(".crontime").formValidator({empty: false, onshow: ''}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                                        $("#msg1").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
                                        $("#frequence").change();
                                    });
                                    $("#type,#frequence").change(function() {
                                        var type = $(this).attr("id");
                                        var val = $(this).val();
                                        $("tr." + type).hide();
                                        $("." + val).show();
                                        $("tr." + type + " td input,tr." + type + " td textarea").unFormValidator(true);
                                        $("tr." + val + " td input,tr." + val + " td textarea").unFormValidator(false);
                                    });
                                </script>
                                </body>
                                </html>
